/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.situacaocheque;

import br.edu.cheque.Cheque;
import br.edu.situacao.Situacao;
import br.edu.util.GenericDAO;
import br.edu.util.HibernateUtil;
import java.util.List;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author 'Pedro
 */
public class SituacaoChequeDAO extends GenericDAO<SituacaoCheque> {

    public SituacaoChequeDAO() {
        super(SituacaoCheque.class);
    }
    
    public List<SituacaoCheque> pesquisarSituacaoCheque(Cheque cheque) {
        List<SituacaoCheque> situacoes=null;
        setSessao(HibernateUtil.getSessionFactory().openSession());
        setTransacao(getSessao().beginTransaction());
        situacoes = (List<SituacaoCheque>) getSessao().createCriteria(SituacaoCheque.class).
                add(Restrictions.eq("cheque", cheque)).list();
        getSessao().close();
        return situacoes;
    }

    public boolean salvar(SituacaoCheque sitcheque) {
        if (sitcheque.getId() == 0) {
            adicionar(sitcheque);
        } else {
            atualizar(sitcheque);
        }
        return true;
    }
}
